#ifndef MYOBJECT_H
#define MYOBJECT_H

#include <QObject>
#include"customEvent.h"
#include <QDebug>

class MyObject : public QObject {

public:
    MyObject(){}
    ~MyObject(){}

protected:
    bool event(QEvent *event) override
    {
        // 是我的自定义事件
        if (event->type() == CustomEvent::CustomEventType)
        {
            CustomEvent *customEvent = static_cast<CustomEvent *>(event);
            //把它里面的值取出来
            qDebug() << "Received custom event with data:" << customEvent->customData();

            return true; // 返回true表示事件已被处理
        }
        //不是我的自定义事件,把事件还给基类继续循环
        // 对于其他事件，调用基类的event函数
        return QObject::event(event);
    }
};

#endif // MYOBJECT_H

